package com.fourpigeon.dao;

import com.fourpigeon.domain.AgreeInfo;
import com.fourpigeon.domain.BlogComment;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface BlogCommentDao {
    @Select("select * from tb_blog_comments where id = #{id} and status < 2")
    public BlogComment getById(Long id);
    //分页查询
//    @Select("select * from tb_blog_comments where blogId = #{blogId} and id < #{start} order by createTime ASC, id ASC limit 6")
//    public List<BlogComment> getPageByBlogId(Integer blogId,Integer start);
    @Select("select * from tb_blog_comments where blogId = #{blogId} and stage > #{start} and status < 2 order by createTime ASC, id ASC limit 6")
    public List<BlogComment> getPageByBlogId(Long blogId,Long start);
    @Insert("insert into tb_blog_comments values(#{id},#{userId},#{userName},#{icon},#{blogId},#{stage},#{content},#{likes},#{isLike},#{status},#{createTime},#{updateTime})")
    public boolean save(BlogComment agreeInfo);
    @Delete("delete from tb_blog_comments where id = #{id} and status < 2")
    public boolean delete(Long id);

    @Update("update tb_blog_comments set likes=likes+1 where id = #{id} and status < 2")
    public boolean addLike(Long id);

    @Update("update tb_blog_comments set likes=likes-1 where id = #{id} and status < 2")
    public boolean subLike(Long id);
}
